﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;

namespace AJAXTreeViewControl
{
    /// <summary>
    /// Summary description for ServerControl1
    /// </summary>
    public class AjaxTreeView : ScriptControl
    {
        public string LoadingImageUrl
        {
            get;
            set;
        }
        public string AjaxWebServiceMethod
        {
            get;
            set;
        }
        public string TreeContainerID
        {
            get;
            set;
        }
        public AjaxTreeView()
        {
            
        }
        protected override IEnumerable<ScriptDescriptor>
                GetScriptDescriptors()
        {
            ScriptControlDescriptor descriptor = new ScriptControlDescriptor("AJAXTreeViewControl.AjaxTreeView", this.ClientID);

            descriptor.AddProperty("AjaxWebServiceMethod", AjaxWebServiceMethod);
            descriptor.AddProperty("TreeContainerID", TreeContainerID);
            descriptor.AddProperty("LoadingImageUrl", LoadingImageUrl);

            yield return descriptor;
        }

        // Generate the script reference
        protected override IEnumerable<ScriptReference>
                GetScriptReferences()
        {
            yield return new ScriptReference("AJAXTreeViewControl.AjaxTreeView.js", this.GetType().Assembly.FullName);
        }
/*
        protected override void OnPreRender(System.EventArgs e)
        {
            base.OnPreRender(e);

            ScriptManager manager = ScriptManager.GetCurrent(this.Page);
            manager.RegisterScriptControl(this);
        }

        protected override void Render(HtmlTextWriter writer)
        {
            base.Render(writer);

            ScriptManager manager = ScriptManager.GetCurrent(this.Page);
            manager.RegisterScriptDescriptors(this);
        } 
        */

    }
}